<template>
  <view class="becomeAgent">
    <image
      src="../../../../static/business/totrue.png"
      mode="scaleToFill"
    />
    <view class="becomebtn">
      <view class="text" v-if="status === 0">是否申请代理</view>
      <view class="text" v-if="status === 1">商家审核中</view>
      <view class="text" v-if="status === 2">以成为代理</view>
      <view class="useBtn">
        <button @click="concel" class="concel">取消</button>
        <button @click="sure" class="sure">确定</button>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
import { agent, getAgent } from '@/service/index.ts'
import { onShow } from "@dcloudio/uni-app"

const emits = defineEmits(['close'])

const status = ref()

const props = defineProps({
  id: {
    type: Number,
    default: 0
  }
})

const goToAgent = () => {
  getAgent({id:props.id}).then(res => {
    status.value = res.status
  })
}

onShow(() => {
  goToAgent()
})

// 取消
const concel = () => {
  emits('close')
}

// 确定
const sure = () => {
  agent({id:props.id}).then(res => {
    status.value = res.status
    close()
  })
}
</script>

<style lang="scss" scoped>
 .becomeAgent {
  position: relative;
  height: 451rpx;
  .becomebtn {
    position: absolute;
    top: 264rpx;
    left: 50%;
    transform: translateX(-50%);
  }
  .text {
    font-family: Source Han Sans CN;
    font-weight: 500;
    font-size: 34rpx;
    color: #00C1FF;
    line-height: 30rpx;
    text-align: center;
    margin-bottom: 55rpx;
  }
  .useBtn {
    display: flex;
    .concel {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 209rpx;
      height: 64rpx;
      background: #112959;
      border-radius: 32rpx;
      border: 2px solid rgba(0,0,0,0.73);
      font-family: Source Han Sans CN;
      font-weight: 500;
      font-size: 30rpx;
      color: #00C1FF;
      line-height: 30rpx;
      border: 1px solid #00C1FF;
      margin-right: 18rpx;
    }
    .sure {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 209rpx;
      height: 64rpx;
      background: #00C1FF;
      border-radius: 32rpx;
      font-family: Source Han Sans CN;
      font-weight: 500;
      font-size: 30rpx;
      color: #112959;
      line-height: 30rpx;
      margin-left: 18rpx;
    }
  }
 }
</style>
